<?php
/**
 * Created by PhpStorm.
 * User: samsung
 * Date: 2018/8/12
 * Time: 15:32
 */

namespace app\index\controller;

use app\index\model\User;
use think\Db;
//绑定了数据表的一张表，返回一个对象
class Demo6
{
    public function get(){
        //dump(User::get(1));
        //模型操作数据库查询
        //$res = User::field('id,username,password,address')->where('id',9)->find();
        //dump($res);
        //原始数据库查询
        //$res = Db::table('user')->field('id,username,password,address')->where('id',9)->find();
        //dump($res);
    }

    public function getall(){
        //$res = User::all(); //全都数据
        //$res = User::all([1,2,3]); //查询部分数据

        $res = User::field('id,username,password,address')
            ->where('id','in','1,2,3')
            ->select();
        dump($res);
        dump($res instanceof User);//判断是否为User的一个实例对象
    }
}